package org.zkoss.zktc.core.groovy;

import groovy.lang.Binding;

import java.util.Properties;
import java.util.Map.Entry;

public class BindingLoader {

	public static Binding load(Properties config){
		return load(config,new Binding());
	}
	public static Binding load(Properties config,Binding binding){
		for(Entry e:config.entrySet()){
			String k = e.getKey().toString();
			final String prefix = "zktc.groovy.binding.";
			if(k.startsWith(prefix)){
				binding.setVariable(k.substring(prefix.length()),e.getValue().toString());
			}
		}
		return binding;
	}
}
